#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <math.h>
#include <string.h>

int main() {
	char buf[16][32] = {0};

	int n;
	scanf("%d", &n);

	for(int i = 0; i < min(n, 16); i++){
		scanf("%30s", buf[i]);
	}

	char* out[2048] = {0};
	int index;
	
	while (scanf("%d", &index) != EOF) {
		strcat(out, buf[index]);
		strcat(out, " ");
	}
	out[strlen(out) - 1]=0;
	puts(out);
}